﻿using System;
using System.IO;

class FileNameAndPath
{
    static void Main()
    {
        //Exercise 3.
        //Write a program that enters file name along with its full file path (e.g. C:\WINDOWS\win.ini), reads its contents and 
        //prints it on the console. Find in MSDN how to use System.IO.File.ReadAllText(...). Be sure to catch all possible 
        //exceptions and print user-friendly error messages.

        try
        {            
            Console.Write("Enter the full file path: ");
            string filePath = Console.ReadLine();
            string fileContent = File.ReadAllText(filePath);       
        }
        catch (DirectoryNotFoundException)
        {
            Console.WriteLine("The specified filepath cannot be found!");
        }
        catch (FileNotFoundException)
        {
            Console.WriteLine("The file was not found!");
        }
        catch (ArgumentException)
        {
            Console.WriteLine("The file path is not correct!");
        }
        catch (PathTooLongException)
        {
            Console.WriteLine("The entered file path is too long - 248 characters are the maximum!");
        }
        catch (UnauthorizedAccessException unauthorized)
        {
            Console.WriteLine(unauthorized.Message);
        }
        catch (NotSupportedException)
        {
            Console.WriteLine("Invalid file path format!");
        }
        catch (IOException ioEx)
        {
            Console.WriteLine(ioEx.Message);
        }
        catch (Exception ex)
        {
            Console.WriteLine("{0} - {1}", ex.GetType(), ex.Message);
        }
    }
}

